#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
@Time 2024-02-01 22:53
@Author: wanbo
@Despcription: 相当于 python 中的 switch 语句, 从 Python3.10 版本以后才加入
'''

list_a = [400, 500, 600, 700, 900]

for item in list_a:
    match item:
        case 400:
            print("The number is 400")
        case 600:
            print("Now it's 600")
        case (500|1000):
            print("The number is 500 or 1000")
        case _:
            print("this is default", item)
# TODO: _ 下划线相当于default关键字 
# TODO: | 符号连接多个字面值
# TODO: macth语句中不需要break
            

points = [(0, 5), (1, 0), (3, 10), (7, 8, 9)]
for point in points:
    match point:
        case (3, 10):
            print("get point (3,10)")
        case (0, y):
            print("x=0, get point (0,{})".format(y))
        case (x, 0):
            print("y=0, get point ({},0)".format(x))
        # case _:
        #     raise ValueError("Invalid point", point)

# 匹配元祖时可以进行字面值绑定，只确定一个， 另外一个不确定， 也可以匹配到
